<%@page import="com.crossriver.crgis.database.model.Transactions"%>
<%@page import="com.crossriver.crgis.database.service.TransactionsLocalServiceUtil"%>
<%@page import="com.liferay.portal.service.OrganizationLocalServiceUtil"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@page import="com.liferay.portal.model.User"%>
<%@page import="java.util.List"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@ include file="/init.jsp"%>

<portlet:defineObjects />

<div id="main">
	<h1>Transactions</h1>
	<div class="content">
		<p>Below are a list of all transactions made by customers/clients via the CRGIS Online Portal. To view transaction details,
		simply click the <liferay-ui:icon image="view"/> icon in the Action Column.</p><hr>

	 <aui:layout>
	 	<aui:column columnWidth="100">
	 		 	
	 		<%
				
			ThemeDisplay themeDiply = (ThemeDisplay) request
			.getAttribute(WebKeys.THEME_DISPLAY);
			
			String userId = "" + themeDiply.getUserId(); 
				
			%>
				
	 		<% 
				PortletURL iteratorURLSend = renderResponse.createRenderURL();
				iteratorURLSend.setParameter("jspPage", "/html/botransactions/view.jsp");
			%>
						
			<liferay-ui:search-container id="users" 
				emptyResultsMessage="no-transaction-found" delta="20" iteratorURL="<%= iteratorURLSend %>" >
				<liferay-ui:search-container-results>
					<%
						
							List<Transactions> tempTransactions = TransactionsLocalServiceUtil.getAllTransactions();
	
							results = ListUtil.subList(tempTransactions,
								searchContainer.getStart(),
								searchContainer.getEnd());
		
							total = tempTransactions.size();
		
							pageContext.setAttribute("results", results);
							pageContext.setAttribute("total", total);
					%>
				</liferay-ui:search-container-results>
	
				<liferay-ui:search-container-row 
					className="com.crossriver.crgis.database.model.Transactions" keyProperty="transactionNo" modelVar="transaction">
	
					<%
						SimpleDateFormat sdf = new SimpleDateFormat( "dd MMM yyyy hh:mm:ss");
						String paymentDate =  sdf.format(transaction.getPaymentDate());
					%>
	
					<liferay-ui:search-container-column-text name="Payment Date" value="<%= paymentDate%>" />
					<liferay-ui:search-container-column-text name="Transaction No" property="transactionNo" />
					<liferay-ui:search-container-column-text name="Payment Type" property="paymentType" />
					<liferay-ui:search-container-column-text name="Amount Paid" property="amount" />
					<liferay-ui:search-container-column-text name="Reference No" property="transactionRef" />
					<liferay-ui:search-container-column-text name="Status" property="status" />
					<liferay-ui:search-container-column-jsp name="Action" path="/html/botransactions/display_actions.jsp" align="right" />
	
					<%
						long groupId = themeDiply.getLayout().getGroupId();
						String name = User.class.getName();
						//String usrId = String.valueOf(user.);
					%>
				</liferay-ui:search-container-row>
				<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
			</liferay-ui:search-container>
	 	</aui:column>
	 </aui:layout>     

	</div>
</div>